package org.esprit.ocm.client.rpc.ec2;

import org.esprit.ocm.dto.impl.AwsCredentialsDto;
import org.esprit.ocm.dto.impl.ServerDto;

import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

@RemoteServiceRelativePath("RulesService.rpc")
public interface RulesService extends RemoteService {

	/**
	 * Add incoming permissions to a group by opening the given ports.
	 * 
	 * @param instance
	 * @param groupname
	 *            name of the group.
	 * @param protocol
	 *            e.g. "tcp", "udp", "icmp"
	 * @param portFrom
	 * @param portTo
	 * @param cidrIp
	 *            CIDR IP range to add (i.e. 0.0.0.0/0)
	 * 
	 * @return true if successfull, false else
	 */
	public boolean addPermission(String groupname, String protocol, int portFrom, int portTo, String cidrIp, ServerDto server, AwsCredentialsDto credentials);

	/**
	 * Adds a permission associated to an group/owner.
	 * 
	 * @param groupname
	 *            name of group to modify
	 * @param secGroupName
	 *            name of security group to add access
	 * @param secGroupOwnerId
	 *            owner of security group
	 * @return
	 */
	public boolean addPermission(String groupname, String secGroupName, String secGroupOwnerId, ServerDto server, AwsCredentialsDto credentials);

	/**
	 * Revokes permissions that were added using <code>addPermission()</code>.
	 * 
	 * @param instance
	 * @param groupname
	 * @param protocol
	 * @param portFrom
	 * @param portTo
	 * @param cidrIp
	 *            CIDR IP range to add (i.e. 0.0.0.0/0)
	 * 
	 * @return true if successfull, false else
	 */
	public boolean removePermission(String groupname, String protocol, int portFrom, int portTo, String cidrIp, ServerDto server, AwsCredentialsDto credentials);

	/**
	 * Revokes a permission associated to an group/owner.
	 * 
	 * @param groupname
	 *            name of group to modify
	 * @param secGroupName
	 *            name of security group to revoke access from
	 * @param secGroupOwnerId
	 *            owner of security group to revoke access from
	 * @return
	 */
	public boolean removePermission(String groupname, String secGroupName, String secGroupOwnerId, ServerDto server, AwsCredentialsDto credentials);
}
